#ifndef DECISIONTREE_H
#define DECISIONTREE_H

#include <vector>
#include "decision.h"
#include "player.h"
#include "npc.h"

using namespace std;

class decisionTree{
	public: 
		decisionTree();
		~decisionTree();
		
		void addNodeToTree(decisionTreeNode* node);
		void makeDecision(npc* npcGuy);
		void addPlayer(player* player);
		
		player* dude;
		decisionTreeNode* root;
};

//Constructor
decisionTree::decisionTree(){
	root=NULL;
}

//Destructor
decisionTree::~decisionTree(){
}

//Adds the root node
void decisionTree::addNodeToTree(decisionTreeNode* node){
		root=node;
}

//Adds the player object
void decisionTree::addPlayer(player* player){
	this->dude=player;
}

//Starts at the root node and goes through the tree. When it finds a 
//leaf (true and false nodes will equal null), cause an action to happen  
void decisionTree::makeDecision(npc* npcGuy){
	decisionTreeNode* currentNode=root;
	while(currentNode->trueNode!=NULL&&currentNode->falseNode!=NULL){
		if(currentNode->makeDecision(npcGuy, dude)){
			currentNode=currentNode->trueNode;
		}
	    else currentNode=currentNode->falseNode;
	}
		currentNode->makeDecision(npcGuy,dude);
}
#endif
